package demo1;

import java2d.game.*;

import java.awt.*;
import java.awt.geom.Point2D;

public class Demo {

    public static void main(String[] args) {

        // Create game and start it.
        Game game = new Game("Hello");

        Dimension renderSize = game.getFrame().getRenderSize();
        System.out.println("Render size: " + renderSize);

        // Create a line
        GameObject line = new GameObject();
        line.transform.setPosition(0, 150);
        line.transform.setLocalRotation(90);

        LineRender lineRender = new LineRender();
        lineRender.points.add(new Point2D.Float());
        lineRender.points.add(new Point2D.Float(100f, 0));
        lineRender.color = Color.red;
        lineRender.space = Space.local;
        lineRender.stroke = new BasicStroke(10, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND);

        line.addComponent(lineRender);
        game.getScene().add(line);

        // Create a square
        SpriteGameObject square = new SpriteGameObject("square",
                "classpath:sprites/square.png", 0.5, 0.5);

        game.getScene().add(square);

        // Create string with font
        StringGameObject fontText = new StringGameObject("你好", Color.green);
        Font font = new Font("楷体", Font.PLAIN, 30);
        fontText.setFont(font);
        fontText.setOrigin(0.5, 0.5);
        fontText.transform.setPosition(0, 100);
        game.getScene().add(fontText);
    }
}
